package com.weizhu.swufer.core.filter;

import com.weizhu.swufer.constant.SwuferConstant;
import com.weizhu.swufer.core.annotation.SwuferFilter;
import com.weizhu.swufer.core.entity.InvokeParam;
import com.weizhu.swufer.core.rpc.RpcContext;
import com.weizhu.swufer.core.rpc.RpcRequest;

@SwuferFilter(type = SwuferConstant.FILTER_TYPE_PROVIDER,order = -9999)
public class ProviderContextFilter implements Filter{
    @Override
    public Object doFilter(InvokeParam invokeParam, FilterChain filterChain) throws Exception {
        RpcRequest rpcRequest = invokeParam.getRpcRequest();
        RpcContext.getContext().setContextParameters(rpcRequest.getContextParameters());
        return filterChain.doFilter(invokeParam);
    }
}
